package com.sinocare.report.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sinocare.common.entity.vo.Across;
import com.sinocare.common.result.Result;
import com.sinocare.common.result.ResultCode;
import com.sinocare.report.service.AcrossService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/Across")
@Api(tags = "报表管理接口")
public class AcrossController {
    @Resource
    private AcrossService acrossService;
    //检测指标统揽：查询所有
    @ApiOperation(value = "检测指标统揽：查询所有", notes = "检测指标统揽：查询所有", httpMethod = "GET")
    @RequestMapping(value = "across", method = RequestMethod.GET)
    public Result findJianCe(Integer page , Integer limit, String searchParams) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        Across across= null;
        if(searchParams != null){
            across= objectMapper.readValue(searchParams, Across.class);
        }
        Page page1 = PageHelper.startPage(page, limit);
        List<Across> list1 = acrossService.query(across);
        System.out.println(list1);
        return Result.ok(ResultCode.SUCCESS, page1.getTotal(), list1);
    }

}
